
//
//  UIBarButtonItem+Extension.swift
//  XLWebo
//
//  Created by 陈晓龙 on 17/2/16.
//  Copyright © 2017年 陈晓龙. All rights reserved.
//

import Foundation

extension UIBarButtonItem {
 
    /// 创建UIBbarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: fontSize
    ///   - target: target
    ///   - action: action
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject,action:Selector,isBack:Bool = false) {
        let leftBtn:UIButton = UIButton.cz_textButton(title, fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            leftBtn.setImage(UIImage(named: imageName), for: .normal)
            leftBtn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
            leftBtn.sizeToFit()
        }
        leftBtn.addTarget(target, action: action, for: .touchUpInside)
        
        //实例化UIBbarButtonItem
        self.init(customView:leftBtn)
    }
}
